package com.qijian.maindata.domain.query;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.qijian.common.utils.mybatis.WhereType;
import com.qijian.common.utils.mybatis.WhereTypeEnum;
import lombok.Data;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;


/**
 * 数控(锯切)件工单明细对象 查询条件类
 *
 * @author qijian
 * @date 2021-11-30
 */

@Data
@ToString
@TableName("main_nc_order_detail")
public class NcOrderDetailQuery {

    @WhereType(filed = "detail_id")
    private Long detailId;
    @WhereType(filed = "order_id")
    private Long orderId;
    @WhereType(filed = "nc_id")
    private Long ncId;
    @WhereType(filed = "quantity")
    private Long quantity;
    @WhereType(filed = "wages")
    private BigDecimal wages;
    @WhereType(filed = "remark")
    private String remark;
    @WhereType(filed = "detail_id", type = WhereTypeEnum.IN)
    private Set<Long> ids;
    @WhereType(filed = "detail_id", type = WhereTypeEnum.NOTIN)
    private Set<Long> idsNot;
    @WhereType(filed = "order_id", type = WhereTypeEnum.IN)
    private Set<Long> orderIds;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @WhereType(tableName = "main_nc_order", filed = "create_time", type = WhereTypeEnum.BETWEEN)
    private Date[] createTime;
    @WhereType(tableName = "main_nc_order", filed = "order_type")
    private String orderType;
    @WhereType(tableName = "main_nc_order", filed = "order_code", type = WhereTypeEnum.LIKE)
    private String orderCode;
    @WhereType(tableName = "main_nc", filed = "project_id")
    private Long projectId;
    @WhereType(tableName = "main_project", filed = "project_no", type = WhereTypeEnum.LIKE)
    private String projectNo;
    @WhereType(tableName = "main_project", filed = "machine_no", type = WhereTypeEnum.LIKE)
    private String machineNo;
    @WhereType(tableName = "main_item", filed = "item_high", type = WhereTypeEnum.LIKE)
    private BigDecimal itemHigh;
    @WhereType(tableName = "main_item", filed = "drawing_no", type = WhereTypeEnum.LIKE)
    private String drawingNo;
    @WhereType(tableName = "main_item", filed = "part_no", type = WhereTypeEnum.LIKE)
    private String partNo;
    @WhereType(tableName = "main_item", filed = "item_attr", type = WhereTypeEnum.LIKE, func = "JSON_CONTAINS(item_attr, JSON_OBJECT('name', '厚', 'value', {1}))")
    private BigDecimal itemAttr;

    @WhereType(filed = "dict_label", tableName = "sys_dict_data", type = WhereTypeEnum.LIKE)
    private String statusName;

    @WhereType(tableName = "main_nc_order", filed = "status", type = WhereTypeEnum.NOTIN)
    private Long status;

    @WhereType(tableName = "main_nc_order", filed = "status", type = WhereTypeEnum.NEQ)
    private Long statusNE;

    @WhereType( tableName = "main_nc_order",filed ="business_origin_name",type = WhereTypeEnum.LIKE)
    private String businessOriginName;

    @WhereType( func = " not EXISTS ( SELECT 1 from(SELECT SUM(a.quantity) quantity from main_nc_order_transport_detail a LEFT JOIN main_nc_order_transport b on a.main_id =b.id AND a.is_del = 0 AND b.is_del = 0 " +
            "WHERE a.detail_id = main_nc_order_detail.detail_id and b.transport_type='转运' GROUP BY a.detail_id) t WHERE t.quantity >= main_nc_order_detail.quantity   ) ")
    private Boolean ignoreFlag;

    @WhereType( func = " not EXISTS ( SELECT 1 from(SELECT SUM(a.quantity) quantity from main_nc_order_transport_sawing_detail a LEFT JOIN main_nc_order_transport_sawing b on a.main_id =b.id AND a.is_del = 0 AND b.is_del = 0 " +
            "WHERE a.detail_id = main_nc_order_detail.detail_id and b.transport_type='转运' GROUP BY a.detail_id) t WHERE t.quantity >= main_nc_order_detail.quantity   ) ")
    private Boolean ignoreSawingFlag;

    @WhereType(ignore = true)
    private List<Long> idStr;


    @WhereType(tableName = "main_nc_order_detail", filed = "detail_id", type = WhereTypeEnum.IN)
    private List<Long> idStr_;

    @WhereType(ignore = true)
    private int count;

    @WhereType(ignore = true)
    private String materialNew;


    @WhereType(tableName = "main_project", filed = "project_no", type = WhereTypeEnum.EQ)
    private String projectNoNew;

    @WhereType(filed = "order_id", type = WhereTypeEnum.IN)
    List<Long> orderIdList;

}
